package com.weixing.mall.provider.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.core.support.auth.AuthUtil;
import com.weixing.mall.core.support.auth.SysAuth;
import com.weixing.mall.provider.mapper.OrderLogMapper;
import com.weixing.mall.provider.model.domain.OrderLog;
import com.weixing.mall.provider.service.IOrderLogService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 订单模块-订单操作记录-报表使用 服务实现类
 * </p>
 *
 * @author Small
 * @since 2020-08-17
 */
@Service
public class OrderLogServiceImpl extends ServiceImpl<OrderLogMapper, OrderLog> implements IOrderLogService {

    @Override
    public void addOrderLog(Long orderId,Integer logType,Long uid,String name){
        SysAuth auth = AuthUtil.getSysExt();
        OrderLog orderLog = new  OrderLog();
        orderLog.setOrderId(orderId);
        orderLog.setLogType(logType);
        if(ObjectUtil.isNotEmpty(auth)){
            orderLog.setOperatorId(auth.getUid());
            orderLog.setOperatorName(auth.getRealName());
        }else{
            orderLog.setOperatorId(uid);
            orderLog.setOperatorName(name);
        }
        save(orderLog);
    }

}
